package com.tj.jinzao.common;

import android.content.res.Resources;
import android.os.Environment;

import com.tj.jinzao.App;
import com.tj.jinzao.BuildConfig;

import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
 * App常量
 * Created by wjy on 2015/11/2.
 */
public class Constant {

    //是否打印日志
    public static boolean TRACE = BuildConfig.DEBUG;
    public final static boolean SHOW_DETECT_BITMAP = false;

    public static String WX_APPID="wxd16250ccb9487cf9";
    public static String WX_APPSCREAT="d79010c15ca0574750d40faff71add69";


    public final static String BASE_SERVER_URL = BuildConfig.SERVER == 2 ? " https://xcx.ijinzao.com/portal-jz/" : " https://xcx.ijinzao.com/portal-jz/";
    //通过code获取access_token
    public static final String WX_GETACCESSTOKEN="https://api.weixin.qq.com/sns/oauth2/access_token";
    //通过access_token获取refresh_token
    public static final String WX_GETREFRESHSTOKEN="https://api.weixin.qq.com/sns/oauth2/refresh_token";
    //通过access_token获取用户信息
    public static final String WX_GETUSERINFO="https://api.weixin.qq.com/sns/userinfo";


    //平台
    public static final String PLATFORM = "2";// android

    //SD卡根目录
    public static final String SD_ROOT = Environment.getExternalStorageDirectory().getAbsolutePath();
    //app根目录
    public static final String SD_PATH = SD_ROOT + "/ASAP" + (BuildConfig.DEBUG ? "Test" : "") + "/";
    //声音存放位置
    public static final String SD_VOICE = SD_PATH + "Voice/";
    //图片存放位置
    public static final String SD_IMAGE = SD_PATH + "Pic/";
    //临时目录（上传图片语音使用）
    public static final String SD_TEMP = SD_PATH + "Temp/";
    //TAG前缀
    public static final String TAG_PREFIX = "AS.";
    //下载目录
    public static final String SD_DOWNLOAD = SD_PATH + "Download/";
    //分享默认图
    public static final String SD_SHARE_IMAGE1 = SD_IMAGE + "share1.jpg";
    //分享默认图
    public static final String SD_SHARE_IMAGE2 = SD_IMAGE + "share2.jpg";
    //图片临时目录（发帖上传图片使用）
    public static final String SD_TEMP_IMAGE = SD_PATH + "Temp/";
    //分享默认图
    public static final String LOG_DIR = SD_PATH + "Log/";
    //图片前缀
    public static final String IMAGE_PREFIX = "https://oss.ijinzao.com/Jinzao/";
    //日记话题分割
    public static final String ARTICLE_TAG = "@jin001zao@";
    public static final String ARTICLE_P1 = "<p>";
    public static final String ARTICLE_P2 = "</p>";

    //1年
    public final static long REQUEST_ONE_YEAR_TIME = 24 * 60 * 60000 * 365l;
    //30天
    public final static long REQUEST_ONE_MONTH_TIME = 24 * 60 * 60000 * 30l;
    //24小时
    public final static int REQUEST_ONE_DAY_TIME = 24 * 60 * 60000;
    //1小时
    public final static int REQUEST_ONE_HOUR_TIME = 60 * 60000;
    //1分钟
    public final static int REQUEST_ONE_MINUTE_TIME = 60000;

    //屏幕缩放比率
    public static final int SCREEN_WIDTH;
    public static final int SCREEN_HEIGHT;
    public static final float SCALE_X;
    public static final float SCALE_Y;

    public static int SIGN_BG_INDEX = 0;

    //加载器id
    public final static int LOAD_TYPE_TOPIC = 10000;//单个话题列表

    static {
        Resources resources = App.getInstance().getResources();
        int screenWidth = resources.getDisplayMetrics().widthPixels;
        int screenHeight = resources.getDisplayMetrics().heightPixels;
        if (screenHeight > screenWidth) {
            SCREEN_WIDTH = screenWidth;
            SCREEN_HEIGHT = screenHeight;
        } else {
            SCREEN_WIDTH = screenHeight;
            SCREEN_HEIGHT = screenWidth;
        }
        SCALE_X = SCREEN_WIDTH / 640.0f;
        SCALE_Y = SCREEN_HEIGHT / 1136.0f;
    }
    // 验证手机号是否为正确手机号
    public static boolean isMobileNO(String mobiles) {

        Pattern p = Pattern
                .compile("^(0|86|17951)?(13[0-9]|15[0-9]|17[0-9]|18[0-9]|14[0-9])[0-9]{8}$");

        Matcher m = p.matcher(mobiles);

        return m.matches();
    }

}
